package cn.airfei.demo.pattern.proxy.jdkproxy;

import java.lang.reflect.InvocationHandler;
import java.lang.reflect.Method;

/**
 * @description:
 * @author: air
 * @create: 2020-05-09 10:53
 */
public class AlipayInvocationHandler  implements InvocationHandler {
    private Object targetObject;

    public AlipayInvocationHandler(Object targetObject){
        this.targetObject=targetObject;
    }


    @Override
    public Object invoke(Object proxy, Method method, Object[] args) throws Throwable {
        beforePay();
        Object result=method.invoke(targetObject,args);
        afterPay();
        return result;
    }


    private void afterPay() {
        System.out.println("支付给慕课网");
    }

    private void beforePay() {
        System.out.println("从招商银行取款");
    }
}
